<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/1/17 0017
  Time: 下午 3:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>${sessionScope.title}</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/admin/css/x-admin.css" media="all">
</head>

<body>
<div class="x-body">
    <form action="" method="post" class="layui-form layui-form-pane">
        <div class="layui-form-item">
            <label for="name" class="layui-form-label">
                <span class="x-red">*</span>角色名
            </label>
            <div class="layui-input-inline">
                <input type="text" id="name" name="name" required="" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <button class="layui-btn" lay-submit="" lay-filter="addRoleInfo">增加</button>
        </div>
    </form>
</div>
<script src="/admin/js/x-layui.js" charset="utf-8"></script>
<script src="../../admin/lib/layui/layui.js" charset="utf-8"></script>
<script src="/admin/js/jquery.min.js" charset="utf-8"></script>
<script>
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form()
            ,layer = layui.layer;
        var ids=[];

        //监听提交
        form.on('submit(addRoleInfo)', function(data){
            $("input:checkbox[name='id']:checked").each(function() { // 遍历name=standard的多选框
                ids.push($(this).val());
            });
            var name = $("#name").val();
            if(name=='' || name ==null){
                layer.msg('请填写角色');
                return false;
            }
            $.ajax({
                url:'/adminSystem/addRoleInfo',
                type:'POST',
                data:{
                    name:name
                },
                success:function(data){
                    if(data.data=='true'){
                        layer.msg('添加成功');
                    }else {
                        layer.msg('添加失败，请稍候再试');
                    }
                    setTimeout(function () { //2秒后刷新父页面
                        window.parent.location.reload();
                    }, 2000);
                }
            });
            return false;
        });

    });
    layui.use('element', function(){
        var element = layui.element(); //Tab的切换功能，切换事件监听等，需要依赖element模块
        //监听Tab切换，以改变地址hash值
        element.on('tab(test1)', function(){
            console.log(this);
            console.log("获取到的tabId "+this.getAttribute('lay-id'));
            //location.hash = 'test1='+ this.getAttribute('lay-id');
        });
    });
</script>
</body>

</html>